<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix">
        <span>员工离职访记录</span>
      </div>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="username" label="受访人" align="center" header-align="center"> </el-table-column>
        <el-table-column prop="hrname" label="访谈HR" align="center" header-align="center"> </el-table-column>
      </el-table>
      <resign-index :userid="userid" :iscomment="false"></resign-index>
    </el-card>
  </div>
</template>

<script>
import ResignIndex from "./ResignIndex.vue";
export default {
  components: { ResignIndex },
  data() {
    return {
      userid: "",
      tableData: [{ username: "", hrname: "" }],
      posterid: "",
    };
  },
  created() {
    this.getUrlKey();
    this.getusername();
    this.gethrname();
  },

  methods: {
    getUrlKey() {
      var url = window.location.href; //获取当前url
      this.nowurl = url;
      var dz_url = url.split("#")[0]; //获取#/之前的字符串
      var cs = dz_url.split("?")[1]; //获取?之后的参数字符串
      var cs_arr = cs.split("&"); //参数字符串分割为数组
      var cs = {};
      for (var i = 0; i < cs_arr.length; i++) {
        //遍历数组，拿到json对象
        cs[cs_arr[i].split("=")[0]] = cs_arr[i].split("=")[1];
      }
      this.userid = cs.userid;
      this.posterid = cs.posterid;
      //   this.tableData.username = cs.username;
      //   this.tableData.hrname = cs.hrname;
      //   console.log(this.tableData)
    },

    async getusername() {
      try {
        let res = await this.$axios.get(
          `api/member/getusername?id=` + this.userid
        );
        this.tableData[0].username = res.data;
      } catch (e) {}
    },

    async gethrname() {
      try {
        let res = await this.$axios.get(
          `api/member/getusername?id=` + this.posterid
        );
        this.tableData[0].hrname = res.data;
      } catch (e) {}
    },
  },
};
</script>

<style lang="scss" scoped>
</style>